
# coding:utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header

# 第三方 SMTP 服务
mail_host = "smtp.163.com"  #设置服务器
mail_user = "jameszhangjp@163.com"   #用户名
mail_pass = "coolzjp0927"   #口令

sender = "jameszhangjp@163.com"
receivers = 'cool-zjp@qq.com' # 接收邮件，可设置为你的QQ邮箱或者其他邮箱

message = MIMEText('ParlAI — Facebook 开源的 AI 对话模型研究和训练框架', 'plain', 'utf-8')
message['From'] = Header("From测试", 'utf-8')
message['To'] = Header("To测试", 'utf-8')

subject = 'Python SMTP 邮件测试'
message['Subject'] = Header(subject, 'utf-8')

s = smtplib.SMTP()
s.connect('smtp.163.com', 25)    # 25 为 SMTP 端口号
s.login(sender, 'coolzjp0927')
s.sendmail(sender,[receivers], message.as_string())
s.quit()
print("邮件发送成功")'
import smtplib
from email.mime.text import MIMEText

# 第三方 SMTP 服务
mail_host = "smtp.163.com"  # SMTP服务器
mail_user = "username"  # 用户名
mail_pass = "coolzjp0927"  # 密码

sender = 'jameszhangjp@163.com'  # 发件人邮箱(最好写全, 不然会失败)
receivers = ['cool-zjp@qq.com']  # 接收邮件，可设置为你的QQ邮箱或者其他邮箱


content = '过期教程害死人!'
title = 'Python SMTP Mail Test'  # 邮件主题
message = MIMEText(content, 'plain', 'utf-8')  # 内容, 格式, 编码
message['From'] = "{}".format(sender)
message['To'] = ",".join(receivers)
message['Subject'] = title

try:
    s = smtplib.SMTP(mail_host, 25)  # 启用SSL发信, 端口一般是465
    s.login(mail_user, mail_pass)  # 登录验证
    s.sendmail(sender, receivers, message.as_string())  # 发送
    print("mail has been send successfully.")
except smtplib.SMTPException as e:
    print(e)

